home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / frexp.cpp < prev    next >
C/C++ Source or Header  |  1991-09-24  |  2KB  |  67 lines

  1. # remove exponent from floating point number
  2. # C Interface
  3. # double frexp(double value, int *eptr)
  4. #
  5. # returns significand (#significand# < 1)
  6. #       in *eptr returns n such that value = significand * 2**n
  7. ###############################################################################
  8. # hacked for the 68881 by Michael Ritzert, 5.10.90
  9. ##############################################################################
  10. # addresses of the 68881 data port. This choice is fastest when much data is
  11. # transferred between the two processors.
  12.  
  13. comm =     -6    |    fpu command reg
  14. resp =    -16    |    fpu response reg
  15. zahl =      0    |    fpu data reg
  16.  
  17. # a1:    fpu base register
  18. # a0:    pointer to n
  19. #     sp@(12) address of resulting exponent (n)
  20.  
  21. # waiting loop ...
  22. #
  23. # wait:
  24. # ww:    cmpiw    #0x8900,a0@(resp)
  25. #     beq    ww
  26. # is coded directly by
  27. #    .long    0x0c688900, 0xfff067f8                 (fpu base a1)
  28. # and
  29. # www:    tst.w    a0@(resp)
  30. #    bmi.b    www
  31. # is coded by
  32. #    .word    0x4a68,0xfff0,0x6bfa        | test
  33.     
  34.     .text; .even
  35.  
  36. .globl _frexp
  37.     
  38.     lea    0xfffa50,a0
  39.     movew    #0x5418,a0@(comm)    | load first argument to fp0
  40.     cmpiw    #0x8900,a0@(resp)    | check
  41.     movel    a7@(4),a0@
  42.     movel    a7@(8),a0@
  43.  
  44.     movew    #0x009f,a0@(comm)    | fgetman fp0,fp1
  45.     .word    0x4a68,0xfff0,0x6bfa    | test
  46.  
  47.     movew    #0x001e,a0@(comm)    | fgetexp fp0,fp0
  48.     moveal    a7@(12),a1        | address of n while the fpu is active
  49.     .word    0x4a68,0xfff0,0x6bfa    | test
  50. #ifdef __MSHORT__
  51.     movew    #0x7080,a0@(comm)    | fetch exp (fmovew from fp1)
  52.     .long    0x0c688900, 0xfff067f8
  53.     movew    a0@,a1@            | return exp
  54. #else
  55.     movew    #0x7880,a0@(comm)    | fetch exp (fmovel from fp1)
  56.     .long    0x0c688900, 0xfff067f8
  57.     movel    a0@,a1@            | return exp
  58. #endif
  59.     movew    #0x7400,a0@(comm)    | now fetch significand
  60.     .long    0x0c688900, 0xfff067f8
  61.     movel    a0@,d0
  62.     movel    a0@,d1
  63.     btst    #31,a7@(4)        | test sign of 1st arg
  64.     bge    fini            | arg neg ?
  65.     bset    #31,d0            | =>  negate result
  66. fini:    rts
  67.